package com.zhf.consumerboot;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author: 曾鸿发
 * @create: 2022-07-18 20:09
 **/
@Component
public class RabbitMQListener {

    /**
     * 定义方法进行信息的监听, RabbitListener中的参数用于表示监听的是哪一个队列
     */
    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "${my.rabbitmq.queue}", durable = "true"),
            value = @Queue(value = "ccc", durable = "true"),
            exchange = @Exchange(value = "boot_topic_exchange", type = "topic"),
            key = "boot.haha"
    ))
    public void listenerQueue(Message message){
        System.out.println("message:" + message);
    }

}
